﻿using System;
using System.Collections.Generic;
using KKSG;
using MiniJSON;
using UILib;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUpdater;
using XUtliPoolLib;

namespace XMainClient
{
	// Token: 0x020009DA RID: 2522
	internal class XRechargeDocument : XDocComponent
	{
		// Token: 0x17002DD6 RID: 11734
		// (get) Token: 0x06009962 RID: 39266 RVA: 0x0017F05C File Offset: 0x0017D25C
		public override uint ID
		{
			get
			{
				return XRechargeDocument.uuID;
			}
		}

		// Token: 0x17002DD7 RID: 11735
		// (get) Token: 0x06009963 RID: 39267 RVA: 0x0017F074 File Offset: 0x0017D274
		public VIPTable VIPReader
		{
			get
			{
				return XRechargeDocument._VipReader;
			}
		}

		// Token: 0x17002DD8 RID: 11736
		// (get) Token: 0x06009964 RID: 39268 RVA: 0x0017F08C File Offset: 0x0017D28C
		public PayCardTable PayCardReader
		{
			get
			{
				return XRechargeDocument._PayCardReader;
			}
		}

		// Token: 0x17002DD9 RID: 11737
		// (get) Token: 0x06009965 RID: 39269 RVA: 0x0017F0A4 File Offset: 0x0017D2A4
		public static PayListTable PayTable
		{
			get
			{
				return XRechargeDocument._PayReader;
			}
		}

		// Token: 0x17002DDA RID: 11738
		// (get) Token: 0x06009966 RID: 39270 RVA: 0x0017F0BC File Offset: 0x0017D2BC
		public List<PayBaseInfo> PayInfo
		{
			get
			{
				return this._payInfo;
			}
		}

		// Token: 0x17002DDB RID: 11739
		// (get) Token: 0x06009967 RID: 39271 RVA: 0x0017F0D4 File Offset: 0x0017D2D4
		public List<VIPGiftState> IsGiftGet
		{
			get
			{
				return this._isGiftGet;
			}
		}

		// Token: 0x17002DDC RID: 11740
		// (get) Token: 0x06009968 RID: 39272 RVA: 0x0017F0EC File Offset: 0x0017D2EC
		public List<PayCard> PayCard
		{
			get
			{
				return this._payCard;
			}
		}

		// Token: 0x17002DDD RID: 11741
		// (get) Token: 0x06009969 RID: 39273 RVA: 0x0017F104 File Offset: 0x0017D304
		public uint VipLevel
		{
			get
			{
				return this._vipLevel;
			}
		}

		// Token: 0x17002DDE RID: 11742
		// (get) Token: 0x0600996A RID: 39274 RVA: 0x0017F11C File Offset: 0x0017D31C
		public float TotalPay
		{
			get
			{
				return this._totalPay;
			}
		}

		// Token: 0x0600996B RID: 39275 RVA: 0x0017F134 File Offset: 0x0017D334
		public static void Execute(OnLoadedCallback callback = null)
		{
			XRechargeDocument.AsyncLoader.AddTask("Table/PayList", XRechargeDocument._PayReader, false);
			XRechargeDocument.AsyncLoader.AddTask("Table/Vip", XRechargeDocument._VipReader, false);
			XRechargeDocument.AsyncLoader.AddTask("Table/PayCard", XRechargeDocument._PayCardReader, false);
			XRechargeDocument.AsyncLoader.Execute(callback);
		}

		// Token: 0x0600996C RID: 39276 RVA: 0x0017F190 File Offset: 0x0017D390
		public override void OnAttachToHost(XObject host)
		{
			base.OnAttachToHost(host);
			this.MaxVIPLevel = (uint)(XRechargeDocument._VipReader.Table.Length - 1);
			bool flag = XRechargeDocument._vipColor == null;
			if (flag)
			{
				XRechargeDocument._vipColor = XSingleton<XGlobalConfig>.singleton.GetSequenceList("VIPIntervalColor", false);
			}
			this.m_listPaySucNotify.Clear();
			this.m_NotifyInterval = (float)XSingleton<XGlobalConfig>.singleton.GetInt("RechargeSucNotifyRepeatInterval");
			this.m_NotifyCount = XSingleton<XGlobalConfig>.singleton.GetInt("RechargeSucNotifyRepeatCount");
		}

		// Token: 0x0600996D RID: 39277 RVA: 0x0017F214 File Offset: 0x0017D414
		public VIPTable.RowData GetVipPermissions(uint vip)
		{
			vip = Math.Max(vip, 0U);
			vip = Math.Min(vip, this.MaxVIPLevel);
			return XRechargeDocument._VipReader.GetByVIP((int)vip);
		}

		// Token: 0x0600996E RID: 39278 RVA: 0x0017F248 File Offset: 0x0017D448
		public VIPTable.RowData GetCurrentVipPermissions()
		{
			return this.GetVipPermissions(this._vipLevel);
		}

		// Token: 0x0600996F RID: 39279 RVA: 0x0017F268 File Offset: 0x0017D468
		public void ReqPayAllInfo()
		{
			RpcC2G_GetPayAllInfo rpc = new RpcC2G_GetPayAllInfo();
			XSingleton<XClientNetwork>.singleton.Send(rpc);
		}

		// Token: 0x06009970 RID: 39280 RVA: 0x0017F288 File Offset: 0x0017D488
		public void OnGetPayAllInfo(GetPayAllInfoArg oArg, GetPayAllInfoRes oRes)
		{
			bool flag = oRes.errcode == ErrorCode.ERR_SUCCESS;
			if (flag)
			{
				this.SetAllData(oRes.info);
			}
		}

		// Token: 0x06009971 RID: 39281 RVA: 0x0017F2B4 File Offset: 0x0017D4B4
		private void SetAllData(PayAllInfo info)
		{
			this.SetAllPayInfoData(info);
			bool flag = DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.IsVisible();
			if (flag)
			{
				DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.SetVip();
			}
			this.SetVIPGiftState(info.VipLevelGift);
			bool flag2 = this.RechargeView != null && this.RechargeView.IsVisible();
			if (flag2)
			{
				this.RechargeView.SetVipProgressInfo(this.VipLevel);
				this.RechargeView.RefreshData();
				this.RechargeView.RefreshVIP();
			}
		}

		// Token: 0x06009972 RID: 39282 RVA: 0x0017F338 File Offset: 0x0017D538
		private void SetAllPayInfoData(PayAllInfo info)
		{
			this._payInfo = info.pay;
			this._payCard = info.card;
			this._vipLevel = info.vipLevel;
			this._lastVipLevel = this._vipLevel;
			this._totalPay = info.totalPay / 100f;
		}

		// Token: 0x06009973 RID: 39283 RVA: 0x0017F38A File Offset: 0x0017D58A
		public void PayAllInfoNtf(PayAllInfo info)
		{
			this.SetAllData(info);
		}

		// Token: 0x06009974 RID: 39284 RVA: 0x0017F398 File Offset: 0x0017D598
		public List<PayCardTable.RowData> GetPayCardList()
		{
			List<PayCardTable.RowData> list = new List<PayCardTable.RowData>();
			for (int i = 0; i < XRechargeDocument._PayCardReader.Table.Length; i++)
			{
				bool flag = false;
				bool flag2 = this._payCard != null;
				if (flag2)
				{
					for (int j = 0; j < this._payCard.Count; j++)
					{
						bool flag3 = (long)XRechargeDocument._PayCardReader.Table[i].Type == (long)((ulong)this._payCard[j].type);
						if (flag3)
						{
							flag = true;
							break;
						}
					}
				}
				bool flag4 = !flag;
				if (flag4)
				{
					list.Add(XRechargeDocument._PayCardReader.Table[i]);
				}
			}
			return list;
		}

		// Token: 0x06009975 RID: 39285 RVA: 0x0017F45C File Offset: 0x0017D65C
		public uint GetVipRMB(uint vipLevel)
		{
			for (int i = 0; i < XRechargeDocument._VipReader.Table.Length; i++)
			{
				bool flag = (long)XRechargeDocument._VipReader.Table[i].VIP == (long)((ulong)vipLevel);
				if (flag)
				{
					return XRechargeDocument._VipReader.Table[i].RMB;
				}
			}
			return 0U;
		}

		// Token: 0x06009976 RID: 39286 RVA: 0x0017F4BC File Offset: 0x0017D6BC
		public float LackMoneyToNextVipLevel(uint currVipLevel)
		{
			bool flag = this.IsMaxVip(currVipLevel);
			float result;
			if (flag)
			{
				result = 0f;
			}
			else
			{
				uint vipRMB = this.GetVipRMB(currVipLevel + 1U);
				bool flag2 = vipRMB > this.TotalPay;
				if (flag2)
				{
					result = vipRMB - this.TotalPay;
				}
				else
				{
					result = 0f;
				}
			}
			return result;
		}

		// Token: 0x06009977 RID: 39287 RVA: 0x0017F510 File Offset: 0x0017D710
		public bool IsMaxVip(uint vipLevel)
		{
			for (int i = 0; i < XRechargeDocument._VipReader.Table.Length; i++)
			{
				bool flag = (long)XRechargeDocument._VipReader.Table[i].VIP > (long)((ulong)vipLevel);
				if (flag)
				{
					return false;
				}
			}
			return true;
		}

		// Token: 0x17002DDF RID: 11743
		// (get) Token: 0x06009978 RID: 39288 RVA: 0x0017F560 File Offset: 0x0017D760
		public Dictionary<int, PayMarketingInfo> FirstPayMarketingInfo
		{
			get
			{
				return this.m_FirstPayMarketingInfo;
			}
		}

		// Token: 0x06009979 RID: 39289 RVA: 0x0017F578 File Offset: 0x0017D778
		public void GetPayMarketingInfo()
		{
			XSingleton<XDebug>.singleton.AddLog("GetPayMarketingInfo", null, null, null, null, null, XDebugColor.XDebug_None);
			XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendGameExData("get_reward_info", "");
		}

		// Token: 0x0600997A RID: 39290 RVA: 0x0017F5AC File Offset: 0x0017D7AC
		public void OnGetPayMarketingInfo(List<PayMarketingInfo> listInfo)
		{
			this.m_FirstPayMarketingInfo.Clear();
			for (int i = 0; i < listInfo.Count; i++)
			{
				bool flag = listInfo[i].sendExt != "";
				if (flag)
				{
					this.m_FirstPayMarketingInfo[listInfo[i].diamondCount] = listInfo[i];
				}
			}
			bool flag2 = DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.IsVisible() && DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.currSys == XSysDefine.XSys_GameMall_Pay;
			if (flag2)
			{
				DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.RefreshDiamondPay();
			}
		}

		// Token: 0x0600997B RID: 39291 RVA: 0x0017F64C File Offset: 0x0017D84C
		public void PayParameterNtf()
		{
			return; //TODO:test
			string openkey;
			string pf;
			string pfKey;
			string sessionType;
			string sessionId;
			string appid;
			this.GetPayBillInfo(out openkey, out pf, out pfKey, out sessionType, out sessionId, out appid);
			PtcC2M_PayParameterInfoNtf ptcC2M_PayParameterInfoNtf = new PtcC2M_PayParameterInfoNtf();
			ptcC2M_PayParameterInfoNtf.Data.openkey = openkey;
			ptcC2M_PayParameterInfoNtf.Data.sessionType = sessionType;
			ptcC2M_PayParameterInfoNtf.Data.sessionId = sessionId;
			ptcC2M_PayParameterInfoNtf.Data.pf = pf;
			ptcC2M_PayParameterInfoNtf.Data.pfKey = pfKey;
			ptcC2M_PayParameterInfoNtf.Data.appid = appid;
			XSingleton<XClientNetwork>.singleton.Send(ptcC2M_PayParameterInfoNtf);
		}

		// Token: 0x0600997C RID: 39292 RVA: 0x0017F6D8 File Offset: 0x0017D8D8
		public void GetPayBillInfo(out string openKey, out string pf, out string pfKey, out string sesstionType, out string sesstionID, out string offerid)
		{
			openKey = "";
			pf = "";
			pfKey = "";
			sesstionType = "";
			sesstionID = "";
			offerid = "";
			string payBill = XSingleton<XUpdater.XUpdater>.singleton.XPlatform.GetPayBill();
			bool flag = payBill == "";
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddLog("Pay [GetPayBill] error ", null, null, null, null, null, XDebugColor.XDebug_None);
			}
			else
			{
				Dictionary<string, object> dictionary = Json.Deserialize(payBill) as Dictionary<string, object>;
				bool flag2 = dictionary != null;
				if (flag2)
				{
					object obj;
					bool flag3 = dictionary.TryGetValue("pay_token", out obj);
					if (flag3)
					{
						openKey = obj.ToString();
					}
					object obj2;
					bool flag4 = dictionary.TryGetValue("pf", out obj2);
					if (flag4)
					{
						pf = obj2.ToString();
					}
					object obj3;
					bool flag5 = dictionary.TryGetValue("pfkey", out obj3);
					if (flag5)
					{
						pfKey = obj3.ToString();
					}
					object obj4;
					bool flag6 = dictionary.TryGetValue("sessiontype", out obj4);
					if (flag6)
					{
						sesstionType = obj4.ToString();
					}
					object obj5;
					bool flag7 = dictionary.TryGetValue("sessionid", out obj5);
					if (flag7)
					{
						sesstionID = obj5.ToString();
					}
					object obj6;
					bool flag8 = dictionary.TryGetValue("offerid", out obj6);
					if (flag8)
					{
						offerid = obj6.ToString();
					}
				}
			}
		}

		// Token: 0x0600997D RID: 39293 RVA: 0x0017F824 File Offset: 0x0017DA24
		public void SDKRecharge(int price, string paramID, PayParamType paramType)
		{
			bool flag = XSingleton<UiUtility>.singleton.IsWeakNetwork();
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("PAY_WEAK_NETWORK_TIP"), "fece00");
			}
			this.m_paramID = paramID;
			this.m_paramType = paramType;
			this.m_Price = price;
			this.m_CurrRechargeType = XRechargeDocument.RechargeType.DiamondRecharge;
			XSingleton<XDebug>.singleton.AddLog(string.Concat(new object[]
			{
				"[SDKRecharge] price = ",
				price,
				", paramID",
				paramID
			}), null, null, null, null, null, XDebugColor.XDebug_None);
			XSingleton<XUpdater.XUpdater>.singleton.XPlatform.Pay(price, "", paramID, XSingleton<XAttributeMgr>.singleton.XPlayerData.RoleID, XSingleton<XClientNetwork>.singleton.ServerID);
		}

		// Token: 0x0600997E RID: 39294 RVA: 0x0017F8E4 File Offset: 0x0017DAE4
		public void SDKSubscribe(int price, int buyNum, string serviceCode, string serviceName, string paramID, PayParamType paramType)
		{
			bool flag = XSingleton<UiUtility>.singleton.IsWeakNetwork();
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("PAY_WEAK_NETWORK_TIP"), "fece00");
			}
			this.m_paramID = serviceCode;
			this.m_paramType = paramType;
			this.m_Price = price;
			this.m_CurrRechargeType = XRechargeDocument.RechargeType.Subscribe;
			Dictionary<string, object> dictionary = new Dictionary<string, object>();
			dictionary["buyNum"] = buyNum;
			dictionary["serviceCode"] = serviceCode;
			dictionary["serviceName"] = serviceName;
			dictionary["productId"] = paramID;
			dictionary["remark"] = string.Format("aid={0}", XSingleton<XGlobalConfig>.singleton.GetValue("AID"));
			dictionary["zoneId"] = string.Format("{0}_{1}", XSingleton<XClientNetwork>.singleton.ServerID, XSingleton<XAttributeMgr>.singleton.XPlayerData.RoleID);
			string text = Json.Serialize(dictionary);
			XSingleton<XDebug>.singleton.AddLog("[SDKSubscribe] param = " + text, null, null, null, null, null, XDebugColor.XDebug_None);
			XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendGameExData("pay_for_subscribe", text);
		}

		// Token: 0x0600997F RID: 39295 RVA: 0x0017FA14 File Offset: 0x0017DC14
		public override void Update(float fDeltaT)
		{
			this.m_NotifyTime += fDeltaT;
			bool flag = this.m_NotifyTime > this.m_NotifyInterval;
			if (flag)
			{
				int i = 0;
				while (i < this.m_listPaySucNotify.Count)
				{
					RpcC2M_PayNotify rpcC2M_PayNotify = this.m_listPaySucNotify[i];
					rpcC2M_PayNotify.oArg.count = rpcC2M_PayNotify.oArg.count + 1;
					bool flag2 = rpcC2M_PayNotify.oArg.count > this.m_NotifyCount;
					if (flag2)
					{
						this.m_listPaySucNotify.RemoveAt(i);
						XSingleton<XDebug>.singleton.AddGreenLog(string.Concat(new object[]
						{
							"m_listPaySucNotify.Remove paramid = ",
							rpcC2M_PayNotify.oArg.paramid,
							", count = ",
							rpcC2M_PayNotify.oArg.count
						}), null, null, null, null, null);
					}
					else
					{
						XSingleton<XClientNetwork>.singleton.Send(rpcC2M_PayNotify);
						XSingleton<XDebug>.singleton.AddGreenLog(string.Concat(new object[]
						{
							"m_listPaySucNotify.Resend paramid = ",
							rpcC2M_PayNotify.oArg.paramid,
							", count = ",
							rpcC2M_PayNotify.oArg.count
						}), null, null, null, null, null);
						i++;
					}
				}
				this.m_NotifyTime = 0f;
			}
		}

		// Token: 0x06009980 RID: 39296 RVA: 0x0017FB6C File Offset: 0x0017DD6C
		private void RemoveNotify(PayNotifyArg oArg)
		{
			for (int i = 0; i < this.m_listPaySucNotify.Count; i++)
			{
				RpcC2M_PayNotify rpcC2M_PayNotify = this.m_listPaySucNotify[i];
				bool flag = rpcC2M_PayNotify.oArg.paramid == oArg.paramid && oArg.count == 1;
				if (flag)
				{
					this.m_listPaySucNotify.RemoveAt(i);
					XSingleton<XDebug>.singleton.AddGreenLog(string.Concat(new object[]
					{
						"RemoveNotify paramid = ",
						rpcC2M_PayNotify.oArg.paramid,
						", remove count = ",
						rpcC2M_PayNotify.oArg.count,
						", find count = ",
						oArg.count
					}), null, null, null, null, null);
					break;
				}
			}
		}

		// Token: 0x06009981 RID: 39297 RVA: 0x0017FC44 File Offset: 0x0017DE44
		public void PaySuccessNtf()
		{
			string openkey;
			string pf;
			string pfKey;
			string sessionType;
			string sessionId;
			string appid;
			this.GetPayBillInfo(out openkey, out pf, out pfKey, out sessionType, out sessionId, out appid);
			RpcC2M_PayNotify rpcC2M_PayNotify = new RpcC2M_PayNotify();
			rpcC2M_PayNotify.oArg.type = this.m_paramType;
			rpcC2M_PayNotify.oArg.paramid = this.m_paramID;
			rpcC2M_PayNotify.oArg.amount = this.m_Price;
			rpcC2M_PayNotify.oArg.count = 1;
			PayParameterInfo payParameterInfo = new PayParameterInfo();
			payParameterInfo.openkey = openkey;
			payParameterInfo.sessionType = sessionType;
			payParameterInfo.sessionId = sessionId;
			payParameterInfo.pf = pf;
			payParameterInfo.pfKey = pfKey;
			payParameterInfo.appid = appid;
			rpcC2M_PayNotify.oArg.data = payParameterInfo;
			XSingleton<XClientNetwork>.singleton.Send(rpcC2M_PayNotify);
			this.m_NotifyTime = 0f;
			bool flag = XSingleton<XGlobalConfig>.singleton.GetInt("RechargeSucNotifyRepeat") == 1;
			if (flag)
			{
				this.m_listPaySucNotify.Add(rpcC2M_PayNotify);
			}
			DlgBase<XBlockInputView, XBlockInputBehaviour>.singleton.SetVisible(false, true);
		}

		// Token: 0x06009982 RID: 39298 RVA: 0x0017FD50 File Offset: 0x0017DF50
		public void OnPayNotify(PayNotifyArg oArg, PayNotifyRes oRes)
		{
			bool flag = oRes.errcode > ErrorCode.ERR_SUCCESS;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.errcode, "fece00");
			}
			else
			{
				this.RemoveNotify(oArg);
			}
		}

		// Token: 0x06009983 RID: 39299 RVA: 0x0017FD8C File Offset: 0x0017DF8C
		public void OnPayCallback(string msg)
		{
			XSingleton<XDebug>.singleton.AddLog("Pay [OnPayCallback] msg:" + msg, null, null, null, null, null, XDebugColor.XDebug_None);
			bool flag = this.m_CurrRechargeType == XRechargeDocument.RechargeType.DiamondRecharge || this.m_CurrRechargeType == XRechargeDocument.RechargeType.Subscribe;
			if (flag)
			{
				this.OnRechargeAndSubscribeCallback(msg);
			}
			else
			{
				bool flag2 = this.m_CurrRechargeType == XRechargeDocument.RechargeType.BuyGoods;
				if (flag2)
				{
					this.OnBuyGoodsPayCallback(msg);
				}
				else
				{
					bool flag3 = this.m_CurrRechargeType == XRechargeDocument.RechargeType.PandoraBuyGoods;
					if (flag3)
					{
						this.OnPandoraBuyGoodsCallback(msg);
					}
				}
			}
			ILuaEngine xluaEngine = XSingleton<XUpdater.XUpdater>.singleton.XLuaEngine;
			xluaEngine.hotfixMgr.OnPayCallback(msg, this.m_goodsParamID);
		}

		// Token: 0x06009984 RID: 39300 RVA: 0x0017FE2C File Offset: 0x0017E02C
		private void OnRechargeAndSubscribeCallback(string msg)
		{
			XSingleton<XDebug>.singleton.AddLog("Pay [OnRechargeAndSubscribeCallback] msg:" + msg, null, null, null, null, null, XDebugColor.XDebug_None);
			bool flag = msg == "true" || msg == "Success";
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("PAY_SUCCESS"), "fece00");
				this.CheckGiftBag();
				this.ResetGiftBagBtnCD();
				this.PaySuccessNtf();
				this.GetPayMarketingInfo();
			}
			else
			{
				DlgBase<XBlockInputView, XBlockInputBehaviour>.singleton.SetVisible(false, true);
			}
		}

		// Token: 0x06009985 RID: 39301 RVA: 0x0017FEC4 File Offset: 0x0017E0C4
		private void OnBuyGoodsPayCallback(string msg)
		{
			XSingleton<XDebug>.singleton.AddLog("Pay [OnBuyGoodsPayCallback] msg:" + msg, null, null, null, null, null, XDebugColor.XDebug_None);
			bool flag = msg == "true" || msg == "Success";
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("PAY_SUCCESS_GOODS"), "fece00");
				DlgBase<XBlockInputView, XBlockInputBehaviour>.singleton.SetVisible(false, true);
			}
			else
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("PAY_FAIL_GOODS"), "fece00");
				this.NoticeBusyGoodsFail();
			}
		}

		// Token: 0x06009986 RID: 39302 RVA: 0x0017FF68 File Offset: 0x0017E168
		private void OnPandoraBuyGoodsCallback(string msg)
		{
			XSingleton<XDebug>.singleton.AddLog("Pay [OnPandoraBuyGoodsCallback] msg:" + msg, null, null, null, null, null, XDebugColor.XDebug_None);
			bool flag = msg == "true" || msg == "Success";
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("PAY_SUCCESS_PANDORA"), "fece00");
				XSingleton<XPandoraSDKDocument>.singleton.NoticePandoraBuyGoodsResult("success");
			}
			else
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("PAY_FAIL_PANDORA"), "fece00");
				XSingleton<XPandoraSDKDocument>.singleton.NoticePandoraBuyGoodsResult("fail");
			}
		}

		// Token: 0x06009987 RID: 39303 RVA: 0x00180018 File Offset: 0x0017E218
		private void ResetGiftBagBtnCD()
		{
			XSingleton<XDebug>.singleton.AddLog("Pay [ResetGiftBagBtnCD]", null, null, null, null, null, XDebugColor.XDebug_None);
			bool flag = this.m_paramType != PayParamType.PAY_PARAM_AILEEN;
			if (!flag)
			{
				int @int = XSingleton<XGlobalConfig>.singleton.GetInt("GiftBagBtnClickInterval");
				bool flag2 = @int == 0;
				if (flag2)
				{
					XSingleton<XDebug>.singleton.AddLog("Pay [ResetGiftBagBtnCD] GiftBagBtnClickInterval = 0", null, null, null, null, null, XDebugColor.XDebug_None);
				}
				else
				{
					XSingleton<XDebug>.singleton.AddLog("Pay [ResetGiftBagBtnCD] interval = " + @int.ToString(), null, null, null, null, null, XDebugColor.XDebug_None);
					XWelfareDocument specificDocument = XDocuments.GetSpecificDocument<XWelfareDocument>(XWelfareDocument.uuID);
					specificDocument.ResetGiftBagBtnCD(@int);
				}
			}
		}

		// Token: 0x06009988 RID: 39304 RVA: 0x001800B4 File Offset: 0x0017E2B4
		private void CheckGiftBag()
		{
			XSingleton<XDebug>.singleton.AddLog("Pay [CheckGiftBag]", null, null, null, null, null, XDebugColor.XDebug_None);
			bool flag = XSingleton<XGlobalConfig>.singleton.GetInt("HideGiftBagBtnAtOnce") == 0;
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddLog("Pay [CheckGiftBag] HideGiftBagBtnAtOnce = 0", null, null, null, null, null, XDebugColor.XDebug_None);
			}
			else
			{
				XSingleton<XDebug>.singleton.AddLog("Pay [CheckGiftBag] m_paramType = " + this.m_paramType.ToString(), null, null, null, null, null, XDebugColor.XDebug_None);
				bool flag2 = this.m_paramType != PayParamType.PAY_PARAM_AILEEN;
				if (!flag2)
				{
					XWelfareDocument specificDocument = XDocuments.GetSpecificDocument<XWelfareDocument>(XWelfareDocument.uuID);
					specificDocument.HideGiftBagBtn(this.m_paramID);
				}
			}
		}

		// Token: 0x06009989 RID: 39305 RVA: 0x00180160 File Offset: 0x0017E360
		public void SDKBuyGoods(uint id, uint goodsCount, ulong toRoleID, string text, string paramID, uint price)
		{
			XSingleton<XDebug>.singleton.AddLog(string.Concat(new object[]
			{
				"[SDKBuyGoods] id = ",
				id,
				", goodsCount = ",
				goodsCount,
				", toRoleID = ",
				toRoleID,
				",text = ",
				text,
				", paramID = ",
				paramID,
				", price = ",
				price
			}), null, null, null, null, null, XDebugColor.XDebug_None);
			bool flag = XSingleton<XUpdater.XUpdater>.singleton.XPlatform.Platfrom() != XPlatformType.Standalone && !Application.isEditor;
			if (flag)
			{
				DlgBase<XBlockInputView, XBlockInputBehaviour>.singleton.SetVisible(true, true);
			}
			bool flag2 = XSingleton<UiUtility>.singleton.IsWeakNetwork();
			if (flag2)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("PAY_WEAK_NETWORK_TIP"), "fece00");
			}
			string openkey;
			string pf;
			string pfKey;
			string sessionType;
			string sessionId;
			string appid;
			this.GetPayBillInfo(out openkey, out pf, out pfKey, out sessionType, out sessionId, out appid);
			PayParameterInfo payParameterInfo = new PayParameterInfo();
			payParameterInfo.openkey = openkey;
			payParameterInfo.sessionType = sessionType;
			payParameterInfo.sessionId = sessionId;
			payParameterInfo.pf = pf;
			payParameterInfo.pfKey = pfKey;
			payParameterInfo.appid = appid;
			RpcC2G_PayFriendItem rpcC2G_PayFriendItem = new RpcC2G_PayFriendItem();
			rpcC2G_PayFriendItem.oArg.payparam = payParameterInfo;
			rpcC2G_PayFriendItem.oArg.goodsid = id;
			rpcC2G_PayFriendItem.oArg.count = goodsCount;
			rpcC2G_PayFriendItem.oArg.toroleid = toRoleID;
			rpcC2G_PayFriendItem.oArg.text = text;
			XSingleton<XClientNetwork>.singleton.Send(rpcC2G_PayFriendItem);
		}

		// Token: 0x0600998A RID: 39306 RVA: 0x001802FC File Offset: 0x0017E4FC
		public void OnGetBuyGoodsOrder(PayFriendItemArg oArg, PayFriendItemRes oRes)
		{
			bool flag = oRes.ret > ErrorCode.ERR_SUCCESS;
			if (flag)
			{
				DlgBase<XBlockInputView, XBlockInputBehaviour>.singleton.SetVisible(false, true);
				XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.ret, "fece00");
			}
			else
			{
				bool flag2 = XSingleton<UiUtility>.singleton.IsWeakNetwork();
				if (flag2)
				{
					XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("PAY_WEAK_NETWORK_TIP"), "fece00");
				}
				this.m_goodsUrl = oRes.billno;
				this.m_goodsParamID = oRes.paramid;
				this.m_goodsPrice = oRes.price;
				this.m_CurrRechargeType = XRechargeDocument.RechargeType.BuyGoods;
				Dictionary<string, object> dictionary = new Dictionary<string, object>();
				dictionary["zoneId"] = XSingleton<XClientNetwork>.singleton.ServerID.ToString();
				dictionary["productId"] = oRes.paramid;
				dictionary["buyNum"] = oArg.count;
				dictionary["price"] = oRes.price;
				dictionary["tokenUrl"] = oRes.url_param;
				dictionary["extInfo"] = oRes.billno;
				string text = Json.Serialize(dictionary);
				XSingleton<XDebug>.singleton.AddLog("[OnGetBuyGoodsOrder] param = " + text, null, null, null, null, null, XDebugColor.XDebug_None);
				XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendGameExData("pay_for_props", text);
				DlgBase<XBlockInputView, XBlockInputBehaviour>.singleton.SetVisible(false, true);
			}
		}

		// Token: 0x0600998B RID: 39307 RVA: 0x00180468 File Offset: 0x0017E668
		private void NoticeBusyGoodsFail()
		{
			PtcC2M_PayBuyGoodsFailNtf ptcC2M_PayBuyGoodsFailNtf = new PtcC2M_PayBuyGoodsFailNtf();
			ptcC2M_PayBuyGoodsFailNtf.Data.token = this.m_goodsUrl;
			XSingleton<XClientNetwork>.singleton.Send(ptcC2M_PayBuyGoodsFailNtf);
			DlgBase<XBlockInputView, XBlockInputBehaviour>.singleton.SetVisible(false, true);
		}

		// Token: 0x0600998C RID: 39308 RVA: 0x001804A7 File Offset: 0x0017E6A7
		public void SDKPandoraBuyGoods(string json)
		{
			this.m_CurrRechargeType = XRechargeDocument.RechargeType.PandoraBuyGoods;
			XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendGameExData("pay_for_pandora", json);
		}

		// Token: 0x0600998D RID: 39309 RVA: 0x001804C8 File Offset: 0x0017E6C8
		public void SendGetVIPGiftQuery(int level)
		{
			RpcC2G_BuyVipLevelGift rpcC2G_BuyVipLevelGift = new RpcC2G_BuyVipLevelGift();
			rpcC2G_BuyVipLevelGift.oArg.vipLevel = level;
			XSingleton<XClientNetwork>.singleton.Send(rpcC2G_BuyVipLevelGift);
		}

		// Token: 0x0600998E RID: 39310 RVA: 0x001804F8 File Offset: 0x0017E6F8
		public void OnGetVIPGift(int level)
		{
			this.IsGiftGet[level] = VIPGiftState.GET;
			this.CalVipRedPoint();
			bool flag = this.RechargeView != null && this.RechargeView.IsVisible() && this.isVIPShow;
			if (flag)
			{
				this.RechargeView.RefreshGiftState(level);
			}
		}

		// Token: 0x0600998F RID: 39311 RVA: 0x0018054C File Offset: 0x0017E74C
		public bool CalVipRedPoint()
		{
			for (int i = 0; i < this.IsGiftGet.Count; i++)
			{
				bool flag = this.IsGiftGet[i] == VIPGiftState.UNGET;
				if (flag)
				{
					return true;
				}
			}
			XSingleton<XGameSysMgr>.singleton.SetSysRedPointState(XSysDefine.XSys_GameMall_Pay, false);
			XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_GameMall, true);
			return false;
		}

		// Token: 0x06009990 RID: 39312 RVA: 0x001805B4 File Offset: 0x0017E7B4
		public void SetVIPGiftState(List<int> getGiftList)
		{
			this.IsGiftGet.Clear();
			uint num = (this.MaxVIPLevel < this._vipLevel + XRechargeDocument.NEXTVIPLEVELSHOW) ? this.MaxVIPLevel : (this._vipLevel + XRechargeDocument.NEXTVIPLEVELSHOW);
			int num2 = 0;
			while ((long)num2 <= (long)((ulong)num))
			{
				bool flag = (ulong)this._vipLevel >= (ulong)((long)num2);
				if (flag)
				{
					this.IsGiftGet.Add(VIPGiftState.UNGET);
				}
				else
				{
					this.IsGiftGet.Add(VIPGiftState.UNABLE);
				}
				num2++;
			}
			for (int i = 0; i < getGiftList.Count; i++)
			{
				int num3 = getGiftList[i];
				bool flag2 = (long)num3 > (long)((ulong)this._vipLevel);
				if (flag2)
				{
					XSingleton<XDebug>.singleton.AddErrorLog("Error. viplevel = ", this._vipLevel.ToString(), "  but gift is get by level = ", num3.ToString(), null, null);
				}
				this.IsGiftGet[num3] = VIPGiftState.GET;
			}
		}

		// Token: 0x06009991 RID: 39313 RVA: 0x001806B0 File Offset: 0x0017E8B0
		public void ShowVipLevelUp()
		{
			string label = XSingleton<UiUtility>.singleton.ReplaceReturn(string.Format(XStringDefineProxy.GetString("VIPLevelUpTips"), "{n}", "{n}", this._vipLevel));
			string @string = XStringDefineProxy.GetString("VIPLevelUpBtnLabel");
			XSingleton<UiUtility>.singleton.ShowModalDialog(label, @string, new ButtonClickEventHandler(this.ShowCurrentVip), 50);
		}

		// Token: 0x06009992 RID: 39314 RVA: 0x00180714 File Offset: 0x0017E914
		private bool ShowCurrentVip(IXUIButton btn)
		{
			DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetVisible(false, true);
			this.isVIPShow = true;
			bool flag = DlgBase<GameMallDlg, TabDlgBehaviour>.singleton._gamePayDiaMallHander != null && DlgBase<GameMallDlg, TabDlgBehaviour>.singleton._gamePayDiaMallHander.IsVisible();
			if (flag)
			{
				this.ReqPayAllInfo();
				DlgBase<GameMallDlg, TabDlgBehaviour>.singleton._gamePayDiaMallHander.SetSwitchState();
			}
			else
			{
				DlgBase<GameMallDlg, TabDlgBehaviour>.singleton.ShowPurchase(ItemEnum.DIAMOND);
			}
			return true;
		}

		// Token: 0x06009993 RID: 39315 RVA: 0x00180788 File Offset: 0x0017E988
		public static string GetVIPIconString(uint level)
		{
			return "";
		}

		// Token: 0x06009994 RID: 39316 RVA: 0x001807A0 File Offset: 0x0017E9A0
		public static string GetVIPIconNameString(uint level)
		{
			int num = 0;
			for (int i = 0; i < (int)XRechargeDocument._vipColor.Count; i++)
			{
				bool flag = (ulong)level >= (ulong)((long)XRechargeDocument._vipColor[i, 0]) && (ulong)level <= (ulong)((long)XRechargeDocument._vipColor[i, 1]);
				if (flag)
				{
					num = i + 1;
					break;
				}
			}
			bool flag2 = num == 0;
			if (flag2)
			{
				XSingleton<XDebug>.singleton.AddErrorLog(string.Format("Can't find vip{0} 's icon color.", level), null, null, null, null, null);
			}
			return XSingleton<XCommon>.singleton.StringCombine("rechar_vip0", num.ToString());
		}

		// Token: 0x06009995 RID: 39317 RVA: 0x00180844 File Offset: 0x0017EA44
		protected override void OnReconnected(XReconnectedEventArgs arg)
		{
			DlgBase<XBlockInputView, XBlockInputBehaviour>.singleton.SetVisible(false, true);
		}

		// Token: 0x040034A8 RID: 13480
		public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("XRechargeDocument");

		// Token: 0x040034A9 RID: 13481
		public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();

		// Token: 0x040034AA RID: 13482
		private static PayListTable _PayReader = new PayListTable();

		// Token: 0x040034AB RID: 13483
		private static VIPTable _VipReader = new VIPTable();

		// Token: 0x040034AC RID: 13484
		private static PayCardTable _PayCardReader = new PayCardTable();

		// Token: 0x040034AD RID: 13485
		public GamePayDiaMallHander RechargeView;

		// Token: 0x040034AE RID: 13486
		private static SeqList<int> _vipColor;

		// Token: 0x040034AF RID: 13487
		private static readonly uint NEXTVIPLEVELSHOW = 5U;

		// Token: 0x040034B0 RID: 13488
		public uint MaxVIPLevel = 0U;

		// Token: 0x040034B1 RID: 13489
		public bool isVIPShow = false;

		// Token: 0x040034B2 RID: 13490
		private uint _lastVipLevel = 0U;

		// Token: 0x040034B3 RID: 13491
		private List<PayBaseInfo> _payInfo;

		// Token: 0x040034B4 RID: 13492
		private List<VIPGiftState> _isGiftGet = new List<VIPGiftState>();

		// Token: 0x040034B5 RID: 13493
		private List<PayCard> _payCard;

		// Token: 0x040034B6 RID: 13494
		private uint _vipLevel;

		// Token: 0x040034B7 RID: 13495
		private float _totalPay;

		// Token: 0x040034B8 RID: 13496
		private Dictionary<int, PayMarketingInfo> m_FirstPayMarketingInfo = new Dictionary<int, PayMarketingInfo>();

		// Token: 0x040034B9 RID: 13497
		private string m_paramID;

		// Token: 0x040034BA RID: 13498
		private int m_Price;

		// Token: 0x040034BB RID: 13499
		private PayParamType m_paramType;

		// Token: 0x040034BC RID: 13500
		private XRechargeDocument.RechargeType m_CurrRechargeType = XRechargeDocument.RechargeType.None;

		// Token: 0x040034BD RID: 13501
		private List<RpcC2M_PayNotify> m_listPaySucNotify = new List<RpcC2M_PayNotify>();

		// Token: 0x040034BE RID: 13502
		private float m_NotifyTime = 0f;

		// Token: 0x040034BF RID: 13503
		private float m_NotifyInterval = 0f;

		// Token: 0x040034C0 RID: 13504
		private int m_NotifyCount = 0;

		// Token: 0x040034C1 RID: 13505
		private string m_goodsParamID = "";

		// Token: 0x040034C2 RID: 13506
		private uint m_goodsPrice;

		// Token: 0x040034C3 RID: 13507
		private string m_goodsUrl;

		// Token: 0x02001985 RID: 6533
		public enum RechargeType
		{
			// Token: 0x04007ECE RID: 32462
			None,
			// Token: 0x04007ECF RID: 32463
			DiamondRecharge,
			// Token: 0x04007ED0 RID: 32464
			Subscribe,
			// Token: 0x04007ED1 RID: 32465
			BuyGoods,
			// Token: 0x04007ED2 RID: 32466
			PandoraBuyGoods
		}
	}
}
